/*
 * Created on 2005-1-21
 */
package com.tss.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.StringTokenizer;

/**
 * @author DaiRongBang
 *
 * ��ʱ���йصĹ��ܺ���
 */
public class TSSDate {
	public static void main(String args[]) {
		SimpleDateFormat formater = new SimpleDateFormat("HH:mm:ss");
		System.out.println(formater.format(new Date()));
	}
	public static Date parseDate(String strDate) {
		long r=0;
		try
		{
			
			StringTokenizer token = new StringTokenizer(strDate," ");
			String date=token.nextToken();
			Date now=java.sql.Date.valueOf(date);
			r = now.getTime();
			try {
				String time=token.nextToken();
				StringTokenizer tkTime= new StringTokenizer(time,":");
				r += Integer.parseInt(tkTime.nextToken())*60*60*1000;
				r += Integer.parseInt(tkTime.nextToken())*60*1000;
				r += Integer.parseInt(tkTime.nextToken())*1000;
			}
			catch(Exception ex) {
				r = now.getTime();
			}
		}
		catch(Exception ex)
		{
			return new Date();
		}
		return new Date(r);
	}
	
	public static String fullTimeNoFormat() {
		return fullTimeNoFormat(new Date());
	}
	
	public static String fullTimeNoFormat(long date) {
		return fullTimeNoFormat(new Date(date));
	}
	
	public static String fullTimeNoFormat(Date date) {
		String r = "";
		SimpleDateFormat formater = new SimpleDateFormat("yyyyMMddHHmmss");
		try {
			r = formater.format(date);
		} 
		catch(Exception ex) {
			r = formater.format(new Date());
		}
		return r;
	}
	
	public static String fullTime(Date date) {
		String r = "";
		SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			r = formater.format(date);
		} 
		catch(Exception ex) {
			r = formater.format(new Date());
		}
		return r;
	}
	
	public static String fullTime() {
		return fullTime(new Date());
	}
	
	public static String fullTime(long date) {
		return fullTime(new Date(date));
	}
	
	public static String shortDate(Date date) {
		String r = "";
		SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
		try {
			r = formater.format(date);
		} 
		catch(Exception ex) {
			r = formater.format(new Date());
		}
		return r;
	}
	
	public static String shortDate() {
		return shortDate(new Date());
	}
	
	public static String shortDate(long date) {
		return shortDate(new Date(date));
	}
	
	public static String shortTime(Date date) {
		String r = "";
		SimpleDateFormat formater = new SimpleDateFormat("HH:mm:ss");
		try {
			r = formater.format(date);
		} 
		catch(Exception ex) {
			r = formater.format(new Date());
		}
		return r;
	}
	
	public static String shortTime() {
		return shortTime(new Date());
	}
	
	public static String shortTime(long date) {
		return shortTime(new Date(date));
	}
}
